home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-06 / setser.zip / SETSERV.C < prev    next >
C/C++ Source or Header  |  1991-01-22  |  1KB  |  58 lines

  1. /* SetServer ------------------------------------- */
  2. /* Set the server time from the PC's time          */
  3. /* ----------------------------------------------- */
  4. #include <dos.h>
  5. #include <stdio.h>
  6. #include <nit.h>
  7.  
  8. main()
  9. {
  10.     struct date d;
  11.     struct time t;
  12.  
  13.  
  14.     int            i;            /* Temporary Counter */
  15.     int            sconnect;    /* Server Connection Numbers */
  16.     int            pri_server;    /* Current Primary Server */
  17.     int            pre_server;    /* Current Preferred Server */
  18.     char        Sname[48];    /* File Server Name */
  19.  
  20.     getdate(&d);
  21.     gettime(&t);
  22.  
  23.     printf("Server Time Program.  Copyright 1991 by\n");
  24.     printf("\tWhipple & Company\n");
  25.     printf("\t(317)469-7776\n\n");
  26.  
  27.     printf("The current PC time is %2d/%02d/%4d %2d:%02d:%02d\n",
  28.         d.da_mon,d.da_day,d.da_year,
  29.         t.ti_hour, t.ti_min, t.ti_sec);
  30.  
  31.     pri_server = GetPrimaryConnectionID();
  32.     pre_server = GetPreferredConnectionID();
  33.  
  34.     for ( sconnect = 1; sconnect <= 8; sconnect++ ) {
  35.         if ( IsConnectionIDInUse(sconnect)) {
  36.             SetPrimaryConnectionID(sconnect);
  37.             SetPreferredConnectionID(sconnect);
  38.  
  39.             GetFileServerName(sconnect,Sname);
  40.             printf("Setting time on %s  ",Sname);
  41.  
  42.             if (i = SetFileServerDateAndTime(d.da_year,d.da_mon,d.da_day,
  43.                 t.ti_hour,t.ti_min,t.ti_sec)) {
  44.                 if ( i == 198 )
  45.                     printf("** Error: No Console Rights **");
  46.                 else
  47.                     printf("Unknown error: %x",i);
  48.             }
  49.             printf("\n");
  50.         }
  51.     }
  52.  
  53.     SetPrimaryConnectionID(pri_server);
  54.     SetPreferredConnectionID(pre_server);
  55.  
  56.     return 0;
  57. }
  58.